<!--
 * @Descripttion: 
 * @Version: 
 * @Author: gaohj
 * @Date: 2022-11-09 16:10:52
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-11-09 16:31:44
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="text" id="test" style="font-size: 30px;">
        <p>one</p>
        <p>two</p>
        <p>three</p>
        <p>four</p> 
    </div>
    <script>

        // cloneNode()
        // 节点.cloneNode(参数);
        // 参数默认是false  不克隆后代 
        // true 克隆后代节点  


        // 获取元素 

        var divEle = document.querySelector('div');
        var cloneEle = divEle.cloneNode(); // 默认参数是flase
        document.body.appendChild(cloneEle); // 仅仅是克隆div标签 
        
        //<div class="text" id="test" style="font-size: 30px;"></div>
        // 属性也会复制 

        var cloneEle1 = divEle.cloneNode(true); // true会克隆子节点
        



    </script>
</body>
</html>